package com.hzcx.app.simplechat.ui.friend.presenter;

import android.content.Context;

import com.hzcx.app.simplechat.api.BaseDialogObserver;
import com.hzcx.app.simplechat.api.BaseObserver;
import com.hzcx.app.simplechat.base.BasePresenter;
import com.hzcx.app.simplechat.model.FriendModel;
import com.hzcx.app.simplechat.model.HomeModel;
import com.hzcx.app.simplechat.ui.friend.bean.FriendBean;
import com.hzcx.app.simplechat.ui.friend.bean.FriendCityBean;
import com.hzcx.app.simplechat.ui.friend.contract.FriendContract;
import com.hzcx.app.simplechat.ui.home.bean.AddFriendSearchBean;
import com.hzcx.app.simplechat.ui.home.contract.AddFriendSearchContract;
import com.hzcx.app.simplechat.ui.main.bean.FriendRequestCountBean;

import java.util.List;

public class FriendPresenter extends BasePresenter<FriendContract.View> implements FriendContract.Presenter {


    /**
     *  获取好友列表
     * @param context
     */
    @Override
    public void getFriendList(Context context) {
        FriendModel.getFriendBySort(context,null,null, new BaseObserver<List<FriendCityBean>>() {
            @Override
            protected void onSuccess(List<FriendCityBean> data) {
                mView.friendListResult(data);
            }

            @Override
            public void onFailure(Throwable e, String errorMsg) {
                super.onFailure(e, errorMsg);
                mView.onFail();
            }
        });
    }

    /**
     *  获取好友请求新消息条数
     * @param context
     */
    @Override
    public void getFriendRequestCount(Context context) {
        FriendModel.getFriendRequestCount(context, new BaseObserver<FriendRequestCountBean>() {
            @Override
            protected void onSuccess(FriendRequestCountBean data) {
                mView.friendRequestCountResult(data);
            }
        });
    }
}
